package com.laoxu.student.system.controller;

import com.laoxu.student.common.vo.Result;
import com.laoxu.student.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;


/**
 * @author laoxu
 * @since 2020/4/3
 */
@Api(description="系统用户管理")
@CrossOrigin //跨域
@RestController
@RequestMapping("/system/user")
public class UserController {

	@PostMapping("login")
	@ApiOperation(value = "用户登录")
	public Result login(
			@ApiParam(name = "userinfo", value = "系统用户对象", required = true)
			@RequestBody User user){

		return Result.ok().data("token", "admin");
	}

	@GetMapping("info")
	@ApiOperation(value = "获取用户信息")
	public Result info(
			@ApiParam(name = "token", value = "令牌", required = true)
			@RequestParam String token){
		return Result.ok()
				.data("roles", "admin")
				.data("name", "admin")
				.data("avatar","http://b-ssl.duitang.com/uploads/item/201510/17/20151017233057_NTBV3.thumb.224_0.jpeg");
	}

	@PostMapping("logout")
	@ApiOperation(value = "用户登出")
	public Result logout(){
		return Result.ok();
	}
}


